﻿using System;
using System.Data;
using System.Configuration;
using System.IO;
using System.Text;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

namespace Dimok.Web.UI {
	public class TextBoxEx : System.Web.UI.WebControls.TextBox {
		private bool _hide = false;
		public object HideIfZero {
			set {
				double d;
				if (!double.TryParse(value + "", out d)) return;
				if (d == 0d) _hide = true;
			}
		}
		public TextBoxEx() { }

		protected override void OnInit(EventArgs e) {
			base.OnInit(e);
			PreRender += new EventHandler(TextBox_PreRender);
		}

		void TextBox_PreRender(object sender, EventArgs e) {
			if (_hide) Text = "";
		}
	}
}
